﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HeresyManager.Careers;

namespace HeresyManager.HomeWorlds
{
    [Serializable]
    public class FeralWorld : HomeWorld
    {
        private Skill speakLaguage;
        private Trait[] traits;

        public FeralWorld()
        {
       }

        public override string Name
        {
            get { return "Feral World"; }
        }

        public override IEnumerator<Comunication.Comunicator> Acire(Character c)
        {
            speakLaguage = new Skills.SpeakLanguages.SpeakLanguageTribalDialect(Skill.SkillLevel.Skilled);
            traits = new Trait[] { new Traits.IronStomach(), new Traits.Primitive(), new Traits.RiteOfPassage(), new Traits.WildernessSavvy() };
             var e = base.Acire(c);
            while (e.MoveNext())
                yield return e.Current;
            e = c.AddSkill(speakLaguage, this);

            while (e.MoveNext())
                yield return e.Current;

            foreach (var s in traits)
            {
                e = c.AddTrait(s, this);
                while (e.MoveNext())
                    yield return e.Current;
            }
        }

        public override void DeAcire(Character c)
        {
            base.DeAcire(c);
            c.RemoveSkill(speakLaguage, this);
            foreach (var s in traits)
            {
                c.RemoveTrait(s, this);
            }
        }

        #region CharackteristicDices

        public override IDice WeaponSkillDice
        {
            get { return new DiceCollection(new DiceMultiplier(new Dice(10), 2), new DiceNumber(20)); }
        }

        public override IDice BallisitcSkillDice
        {
            get { return new DiceCollection(new DiceMultiplier(new Dice(10), 2), new DiceNumber(20)); }
        }

        public override IDice StrengthDice
        {
            get { return new DiceCollection(new DiceMultiplier(new Dice(10), 2), new DiceNumber(25)); }
        }

        public override IDice ToughnessDice
        {
            get { return new DiceCollection(new DiceMultiplier(new Dice(10), 2), new DiceNumber(25)); }
        }

        public override IDice AgillityDice
        {
            get { return new DiceCollection(new DiceMultiplier(new Dice(10), 2), new DiceNumber(20)); }
        }

        public override IDice IntelligenceDice
        {
            get { return new DiceCollection(new DiceMultiplier(new Dice(10), 2), new DiceNumber(20)); }
        }

        public override IDice PerceptionDice
        {
            get { return new DiceCollection(new DiceMultiplier(new Dice(10), 2), new DiceNumber(20)); }
        }

        public override IDice WillpowerDice
        {
            get { return new DiceCollection(new DiceMultiplier(new Dice(10), 2), new DiceNumber(15)); }
        }

        public override IDice FellowshipDice
        {
            get { return new DiceCollection(new DiceMultiplier(new Dice(10), 2), new DiceNumber(15)); }
        }
        #endregion

        public override Tuple<Type, int, int>[] AccirableCareers
        {
            get { return new Tuple<Type, int, int>[] { new Tuple<Type, int, int>(typeof(Assassin), 1, 30), new Tuple<Type, int, int>(typeof(Guardsman), 31, 80), new Tuple<Type, int, int>(typeof(ImperialPsyker), 81, 90), new Tuple<Type, int, int>(typeof(Scum), 91, 100) }; }
        }

        public override IDice WoundsDice
        {
            get { return new DiceCollection(new Dice(5), new DiceNumber(9)); }
        }

        public override IDice FateDice
        {
            get { return new FunctionDice<int>(new Dice(10), i => { if (i <= 4) return 1; if (i <= 8)return 2; else return 2; }); }
        }

        #region Apereance
        public override Build[] Builds
        {
            get
            {
                return new Build[] {                                                                                                   
                new Build() { Descripton = "Rangy", Gender = Gender.Male, MinRole = 1, MaxRole = 20, Size = 1.90f, Weight = 65 } ,
                new Build() { Descripton = "Lean", Gender = Gender.Male, MinRole = 21, MaxRole = 50, Size = 1.75f, Weight = 60 } ,
                new Build() { Descripton = "Muscular", Gender = Gender.Male, MinRole = 51, MaxRole = 80, Size = 1.85f, Weight = 85 } ,
                new Build() { Descripton = "Squat", Gender = Gender.Male, MinRole = 81, MaxRole = 90, Size = 1.65f, Weight = 80 } ,
                new Build() { Descripton = "Strapping", Gender = Gender.Male, MinRole = 91, MaxRole = 100, Size = 2.10f, Weight = 120 } ,
                new Build() { Descripton = "Rangy", Gender = Gender.Female, MinRole = 1, MaxRole = 20, Size = 1.80f, Weight = 60 } ,
                new Build() { Descripton = "Lean", Gender = Gender.Female, MinRole = 21, MaxRole = 50, Size = 1.65f, Weight = 55 } ,
                new Build() { Descripton = "Muscular", Gender = Gender.Female, MinRole = 51, MaxRole = 80, Size = 1.70f, Weight = 70 } ,
                new Build() { Descripton = "Squat", Gender = Gender.Female, MinRole = 81, MaxRole = 90, Size = 1.55f, Weight = 70 } ,
                new Build() { Descripton = "Strapping", Gender = Gender.Female, MinRole = 91, MaxRole = 100, Size = 2f, Weight = 100 } 
            };
            }
        }

        public override Age[] Ages
        {
            get
            {
                return new Age[] {
                    new Age(){ Description="Warrior", Dice = new DiceCollection(new DiceNumber(15) ,new Dice(10)), MinRole=1, MaxRole=70},
                    new Age(){ Description="Old One", Dice = new DiceCollection(new DiceNumber(25) ,new Dice(10)), MinRole=71, MaxRole=100}
            };
            }
        }

        public override Color[] SkinColors
        {
            get
            {
                return new Color[]{
                    new Color(){ Name="Dark", MinRole = 1, MaxRole=30},
                    new Color(){ Name="Tan", MinRole = 31, MaxRole=50},
                    new Color(){ Name="Fair", MinRole = 51, MaxRole=70},
                    new Color(){ Name="Ruddy", MinRole = 71, MaxRole=90},
                    new Color(){ Name="Bronze", MinRole = 91, MaxRole=100}            
                };
            }
        }

        public override Color[] HairColors
        {
            get
            {
                return new Color[]{
                    new Color(){ Name="Red", MinRole = 1, MaxRole=30},
                    new Color(){ Name="Blond", MinRole = 31, MaxRole=50},
                    new Color(){ Name="Brown", MinRole = 51, MaxRole=70},
                    new Color(){ Name="Black", MinRole = 71, MaxRole=90},
                    new Color(){ Name="Grey", MinRole = 91, MaxRole=100}            
                };
            }
        }

        public override Color[] EyeColors
        {
            get
            {
                return new Color[]{
                    new Color(){ Name="Blue", MinRole = 1, MaxRole=30},
                    new Color(){ Name="Grey", MinRole = 31, MaxRole=50},
                    new Color(){ Name="Brown", MinRole = 51, MaxRole=70},
                    new Color(){ Name="Green", MinRole = 71, MaxRole=90},
                    new Color(){ Name="Yellow", MinRole = 91, MaxRole=100}            
                };
            }
        }

        public override Quirk[] Quirks
        {
            get
            {
                return new Quirk[]{
                    new Quirk(){ Description="Hairy Knuckles", MinRole=1, MaxRole=6},
                    new Quirk(){ Description="Joind Eyebrowns", MinRole=7, MaxRole=13},
                    new Quirk(){ Description="Warpaint", MinRole=14, MaxRole=20},
                    new Quirk(){ Description="Hands like Spatchcocks", MinRole=21, MaxRole=27},
                    new Quirk(){ Description="Filed Teeth", MinRole=28, MaxRole=34},
                    new Quirk(){ Description="Beetling", MinRole=35, MaxRole=41},
                    new Quirk(){ Description="Musky Smell", MinRole=42, MaxRole=48},
                    new Quirk(){ Description="Hairy", MinRole=49, MaxRole=55},
                    new Quirk(){ Description="Ripped Ears", MinRole=56, MaxRole=61},
                    new Quirk(){ Description="Long Fingernails", MinRole=62, MaxRole=68},
                    new Quirk(){ Description="Tribal Tattooing", MinRole=69, MaxRole=75},
                    new Quirk(){ Description="Scarring", MinRole=76, MaxRole=82},
                    new Quirk(){ Description="Pircing", MinRole=83, MaxRole=87},
                    new Quirk(){ Description="Cat's Eyes", MinRole=88, MaxRole=88},
                    new Quirk(){ Description="Small Head", MinRole=89, MaxRole=95},
                    new Quirk(){ Description="Thick Jaw", MinRole=96, MaxRole=100},
            };
            }
        }

        public override string OriginDescription
        {
            get { return "Tribal Taboos"; }
        }

        public override Origin[] Origins
        {
            get
            {
                return new Origin[]{
                     new Origin(){ Description="Dirt Ward", MinRole= 1, MaxRole=10 },
                     new Origin(){ Description="Unlucky Colour", MinRole= 11, MaxRole=20 },
                     new Origin(){ Description="Hunter's Oath", MinRole= 21, MaxRole=30 },
                     new Origin(){ Description="Thirsty Blade", MinRole= 31, MaxRole=40 },
                     new Origin(){ Description="Spirit Shackle", MinRole= 41, MaxRole=50 },
                     new Origin(){ Description="Warrior Death", MinRole= 51, MaxRole=60 },
                     new Origin(){ Description="Power of Names", MinRole= 61, MaxRole=70 },
                     new Origin(){ Description="Lonly Dead", MinRole= 71, MaxRole=80 },
                     new Origin(){ Description="Living Reccord", MinRole= 81, MaxRole=90 },
                     new Origin(){ Description="Nemesis", MinRole= 91, MaxRole=100 },
            };
            }
        }
        #endregion

        public override int MinRole
        {
            get { return 1; }
        }

        public override int MaxRole
        {
            get { return 15; }
        }
    }
}
